<?php
error_reporting(0);
$isadmin=1;    
include '../comm/config.php';	
include 'check.php';

function update_sql($table,$field_arr,$where,$xs,$alert=0){ //$xs 0表示更新 1表示同加  2表示同减,$alert默认为0,1表示打印sql语句,2表示先执行在打印
    global $BIAOTOU;
	$sql="";
	foreach($field_arr as $k=>$v){
		if($xs==0){
		    $sql="`$k`='$v',".$sql;
		}
		elseif($xs==1){
		    $sql="`$k`=`$k`+'$v',".$sql;
		}
		elseif($xs==2){
		    $sql="`$k`=`$k`-'$v',".$sql;
		}
	}
	$sql=substr($sql,0,strlen($sql)-1);
	$sql="update $BIAOTOU$table set $sql where $where;";
	if($alert==0){
		$query=mysql_query($sql);
		if($query==''){
		    echo mysql_error();exit;
		}
	}
	elseif($alert==1){
		echo $sql;
	}
	elseif($alert==2){
		mysql_query($sql);
	    echo $sql; 
	}
}

if(array_key_exists('sign_open',$_POST)){
	$field_arr=$_POST;
    update_sql('websetting',$field_arr,'Id=1',0,0);
    admin_log('保存签到送设置');
	echo "<script language=javascript>window.location='signset.php';</script>";
}

mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td height="30" colspan="2" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="images/arrow.gif" width="16" height="22" align="absmiddle" />签到送设置</strong></td>
            </tr>
            <tr>
              <td width="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><form id="form1" name="form1" method="post" action="signset.php">
                    <table width="100%"  align="center" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                      					  <tr>
                        <td width="129" height="30" align="right" class="bigtext">签到开关：</td>
                        <td width="" height="30" class="bigtext">&nbsp;
                        <label>
                          <select name="sign_open">
                            <option value="1" <?php if(SIGNOPEN==1) echo "selected";?>>开启</option>
                            <option value="0" <?php if(SIGNOPEN==0) echo "selected";?>>关闭</option>
                          </select>
                          </label></td>
                      </tr>
                      <tr>
                        <td height="30" align="right" class="bigtext">每日签到送金额：</td>
                        <td height="30" class="bigtext">&nbsp;<input name="sign_money" type="text" id="sign_money" value="<?=SIGNMONEY;?>" size="10" class="btn3" style="width:100px" /></td>
                      </tr>
                      <tr>
                        <td height="30" align="right" class="bigtext">每日签到送积分：</td>
                        <td height="30" class="bigtext">&nbsp;<input name="sign_jifen" type="text" id="sign_jifen" value="<?=SIGNJIFEN;?>" size="10" class="btn3" style="width:100px" /></td>
                      </tr>
                      <tr>
                        <td height="30" align="right">&nbsp;</td>
                        <td height="30" class="bigtext">&nbsp;
                          <input type="submit" value=" 保 存 设 置 " /> 
                          &nbsp;&nbsp;&nbsp;</td>
                      </tr>
                    </table>
                    
                  </form>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close($link);?>
